package Day15_12;

import java.util.Scanner;

public class Main {
    public static void main1(String[] args) {
        //多状态dp
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] arr = in.next().toCharArray();
        if(n < 3){
            System.out.println(0);
            return;
        }
        long[] s = new long[n];
        if(arr[0] == 's'){
            s[0] = 1;
        }

        long[] sh = new long[n];

        long[] shy = new long[n];

        for(int i = 1; i < n; i++){
            s[i] = arr[i] == 's' ? s[i-1] + 1 : s[i-1];
        }
        for(int i = 1; i < n; i++){
            sh[i] = arr[i] == 'h' ? sh[i-1]+s[i-1] : sh[i-1];
        }
//        for(int e : sh){
//            System.out.print(e + " ");
//        }
//        System.out.println();
        for(int i = 2; i < n; i++){
            shy[i] = arr[i] == 'y' ? shy[i-1]+sh[i-1] : shy[i-1];
        }
//        for(int e : shy){
//            System.out.print(e + " ");
//        }
//        System.out.println();
        System.out.println(shy[n-1]);
    }

    public static void main2(String[] args) {
        //删除公共字符
        //哈希
    }

    public static void main3(String[] args) {
        //两个链表的第一个公共节点
        //双指针
    }
}
